/*
*
* Created by yuri at Apr 2, 2011
*
*/



package implementation.server;


import org.jboss.netty.channel.ChannelPipeline;
import org.jboss.netty.channel.ChannelPipelineFactory;
import org.jboss.netty.channel.Channels;
import org.jboss.netty.channel.group.ChannelGroup;
import org.jboss.netty.handler.codec.serialization.ObjectDecoder;
import org.jboss.netty.handler.codec.serialization.ObjectEncoder;

public class ServerPipelineFactory implements ChannelPipelineFactory {
	
	private ChannelGroup _channels;
	
	private ISessionManager _sessionManager;
	
	public ServerPipelineFactory (ChannelGroup channels, ISessionManager sessionManager) {
		this._channels = channels;
		this._sessionManager = sessionManager;
	}

	@Override
	public ChannelPipeline getPipeline() throws Exception {
		ChannelPipeline pipeline = Channels.pipeline();
		pipeline.addLast("decoder", new ObjectDecoder());
		pipeline.addLast("encoder", new ObjectEncoder());
		pipeline.addLast("handler",new ServerChannelHandler(this._sessionManager,this._channels));
		return pipeline;
	}

}
